package com.kgd.news.ibeetl.func;

import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record;
import com.kgd.news.utils.Constants;
import org.beetl.core.Context;
import org.beetl.core.Function;

import java.util.List;

/**
 * @Email: huangsanm@foxmail.com
 * @Date: 2017/7/26
 * @Time: 下午10:45
 */
public class MenuFunc implements Function {
    @Override
    public Object call(Object[] objects, Context context) {
        //String args = (String) objects[0];
        //String[] objs = args.split(":");
        if(objects.length != 1){
            return "参数错误";
        }
        String id = objects[0] + "";
        List<Record> data =  Db.findByCache(Constants.dict_func_cacheName,"menufunc"+id,"select m.m_name from sys_menu m where id = ?", id);
        if (data != null && !data.isEmpty()) {
            return data.get(0).get("m_name");
        } else {
            return "无";
        }
    }


}
